package com.example.core.service;

import com.example.core.entity.User;
import com.example.core.mapper.UserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    private final UserMapper userMapper;

    public UserService(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public void addUser(String name, String email) {
        User user = new User();
        user.setName(name);
        user.setEmail(email);
        userMapper.insert(user);
    }

    public List<User> getAllUsers() {
        return userMapper.selectList(null);
    }

    public User getUserById(Integer id) {
        return userMapper.selectById(id);
    }
}
